/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2020年9月4日
 */
package com.massyframework.beanskin.assembly;

import com.massyframework.beanskin.ModuleEvent;
import com.massyframework.beanskin.ModuleEventAdapter;

/**
 * {@link AssemblyEventAdapter}在{@link ModuleEventAdapter}的基础上，封装对装配件事件的监听。
 */
public abstract class AssemblyEventAdapter extends ModuleEventAdapter{

    /**
     * 构造方法
     */
    public AssemblyEventAdapter() {
    }
    
    /**
     * 已就绪事件处理
     * @param event {@link AssemblyReadiedEvent}
     */
    protected void onReadied(AssemblyReadiedEvent event){

    }

    /**
     * 已激活事件处理
     * @param event {@link AssemblyActivatedEvent}
     */
    protected void onActivated(AssemblyActivatedEvent event){

    }

    /**
     * 正在退出激活事件处理
     * @param event {@link AssemblyDeactivatingEvent}
     */
    protected void onDeactivating(AssemblyDeactivatingEvent event){

    }

    /**
     * 正在退出就绪事件处理
     * @param event {@link AssemblyUnreadyingEvent}
     */
    protected void onUnreadying(AssemblyUnreadyingEvent event){

    }

	@Override
	protected void dispatchEvent(Class<?> eventType, ModuleEvent event) {
		super.dispatchEvent(eventType, event);
		if (AssemblyReadiedEvent.class == eventType){
            this.onReadied((AssemblyReadiedEvent)event);
            return;
        }

        if (AssemblyActivatedEvent.class == eventType){
            this.onActivated((AssemblyActivatedEvent)event);
            return;
        }

        if (AssemblyDeactivatingEvent.class == eventType){
            this.onDeactivating((AssemblyDeactivatingEvent)event);
            return;
        }

        if (AssemblyUnreadyingEvent.class == eventType){
            this.onUnreadying((AssemblyUnreadyingEvent)event);
            return;
        }
	}

    
}

